package com.vrv.app.cyberspace.modules.sys.controller;


import com.baomidou.mybatisplus.plugins.Page;
import com.vrv.app.cyberspace.common.utils.JSONResult;
import com.vrv.app.cyberspace.common.validator.Assert;
import com.vrv.app.cyberspace.common.validator.ValidatorUtils;
import com.vrv.app.cyberspace.modules.sys.entity.EventManageTable;
import com.vrv.app.cyberspace.modules.sys.service.IEventManageTableService;
import io.swagger.annotations.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.*;
import springfox.documentation.annotations.ApiIgnore;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author sm
 * @since 2018-01-18
 */
@Api(description="事件管理")
@RestController
@RequestMapping("/sys/eventManage")
public class EventManageTableController {
    @Autowired
    private IEventManageTableService eventManageTableService;

    @ApiOperation(value = "事件通知", produces = MediaType.APPLICATION_FORM_URLENCODED_VALUE)
    @ApiResponses(value = {
            @ApiResponse(code = 200, message = "返回成功信息")
    })
    @ApiImplicitParams({
            @ApiImplicitParam(name = "title", value = "标题", required = true, dataType = "String", paramType = "query"),
            @ApiImplicitParam(name = "happenTime", value = "发生日期", required = true, dataType = "String", paramType = "query"),
            @ApiImplicitParam(name = "approvalUserID", value = "请示人ID", required = true, dataType = "String", paramType = "query"),
            @ApiImplicitParam(name = "advice", value = "研判意见", dataType = "String", paramType = "query"),
            @ApiImplicitParam(name = "primaryEventTypeFirst", value = "初判事件类型一级事件", required = true, dataType = "Integer", paramType = "query"),
            @ApiImplicitParam(name = "primaryEventTypeSecond", value = "初判事件类型二级事件", required = true, dataType = "Integer", paramType = "query"),
            @ApiImplicitParam(name = "primaryEventGrade", value = "初判风险等级", required = true, dataType = "Integer", paramType = "query"),
            @ApiImplicitParam(name = "feedBackUpToTime", value = "反馈截止时间", dataType = "String", paramType = "query"),
            @ApiImplicitParam(name = "associatedRisk", value = "测试关联风险", dataType = "String", paramType = "query"),
            @ApiImplicitParam(name = "unitSystemDescription", value = "事发单位及系统功能描述", required = true, dataType = "String", paramType = "query"),
            @ApiImplicitParam(name = "primaryJudgment", value = "事态发展概述及初判原因", required = true, dataType = "String", paramType = "query"),
            @ApiImplicitParam(name = "itemsAdvise", value = "请求事项及工作建议", dataType = "String", paramType = "query"),
            @ApiImplicitParam(name = "infrastructure_information", value = "信息基础设施", dataType = "String", paramType = "query", example = "JSON.stringify([{name: \"测试\",unit: \"\",leadingOfficial: \"\",contactPhone: \"\",ip: \"\",domainName: \"\",url: \"\"}])"),
            @ApiImplicitParam(name = "fax", value = "传真,事件风险都需要", dataType = "String", paramType = "query"),
            @ApiImplicitParam(name = "measureToken", value = "已采取的措施和效果,事件风险都需要", dataType = "String", paramType = "query"),
            @ApiImplicitParam(name = "remarks", value = "备注,事件风险都需要", dataType = "String", paramType = "query"),
            @ApiImplicitParam(name = "enclosure", value = "附件,事件风险都需要", dataType = "String", paramType = "query"),
            @ApiImplicitParam(name = "influenceHarm", value = "影响及危害描述,事件风险都需要", dataType = "String", paramType = "query"),
            @ApiImplicitParam(name = "regionIDs", value = "地域表IDs组合,事件风险都需要", dataType = "String", paramType = "query"),
            @ApiImplicitParam(name = "industryIDs", value = "行业IDs组合,事件风险都需要", dataType = "String", paramType = "query"),
    })
    @PostMapping()
    public JSONResult addToEventManage(Integer id, @ApiIgnore EventManageTable emt, String infrastructure_information, String advice) {
        Assert.isNull(id, "id不能为空");
        ValidatorUtils.validateEntity(emt);
        return eventManageTableService.addToEventManage(id, emt, infrastructure_information, advice);
    }

    @GetMapping("/{baseID}")
    public JSONResult getEventManage(@PathVariable Integer baseID) {
        return eventManageTableService.getEventManage(baseID);
    }

    @ApiOperation(value = "事件管理列表", produces = MediaType.APPLICATION_FORM_URLENCODED_VALUE)
    @ApiResponses(value = {
            @ApiResponse(code = 200, message = "返回事件管理列表")
    })
    @ApiImplicitParams({
            @ApiImplicitParam(name = "page", value = "页码", required = true, dataType = "Integer", paramType = "query"),
            @ApiImplicitParam(name = "size", value = "条数", required = true, dataType = "Integer", paramType = "query"),
            @ApiImplicitParam(name = "startTime", value = "开始时间", dataType = "String", paramType = "query"),
            @ApiImplicitParam(name = "endTime", value = "结束时间", dataType = "String", paramType = "query"),
            @ApiImplicitParam(name = "eventLevel", value = "可多选1,2 事件等级:1特别重大 2重大 3较大 4一般", dataType = "String", paramType = "query"),
            @ApiImplicitParam(name = "eventType", value = "可多选1,2 事件类型", dataType = "String", paramType = "query"),
            @ApiImplicitParam(name = "timeType", value = "时间类型：1为创建时间 2为更新时间", dataType = "Integer", paramType = "query"),
            @ApiImplicitParam(name = "status", value = "预警事件管理状态 1--在办 2--办结", dataType = "Integer", paramType = "query"),
            @ApiImplicitParam(name = "title", value = "标题", dataType = "String", paramType = "query"),
    })
    @GetMapping()
    public JSONResult getEventManageList(Integer page, Integer size, String startTime, String endTime, String eventLevel, String eventType, Integer timeType, Integer status, String title) {
        Assert.isNull(page, "page不能为空");
        Assert.isNull(size, "size不能为空");
        return eventManageTableService.getListEventManage(new Page<>(page, size), startTime, endTime, eventLevel, eventType, timeType, status, title);
    }

    @RequestMapping("/release")
    public JSONResult releaseEvent(EventManageTable emt) {
        return eventManageTableService.releaseEvent(emt);
    }

    @ApiOperation(value = "专家/我的任务", produces = MediaType.APPLICATION_FORM_URLENCODED_VALUE)
    @ApiResponses(value = {
            @ApiResponse(code = 200, message = "返回专家任务列表")
    })
    @ApiImplicitParams({
            @ApiImplicitParam(name = "page", value = "页码", required = true, dataType = "Integer", paramType = "query"),
            @ApiImplicitParam(name = "size", value = "条数", required = true, dataType = "Integer", paramType = "query"),
            @ApiImplicitParam(name = "type", value = "类型：2风险 3事件", required = true, dataType = "Integer", paramType = "query"),
            @ApiImplicitParam(name = "status", value = "状态：0待办 1已办 2办结", required = true, dataType = "Integer", paramType = "query"),
    })
    @GetMapping("/getListProfessorEvent")
    public JSONResult getListProfessorEvent(Integer page, Integer size, Integer status) {
        Assert.isNull(page, "page不能为空");
        Assert.isNull(size, "size不能为空");
        Assert.isNull(size, "type不能为空");
        return eventManageTableService.getListProfessorEvent(new Page<>(page, size), status);
    }
}

